package com.social.config;

import com.social.interceptor.RefreshTokenInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @BelongsProject: social
 * @BelongsPackage: com.social.config
 * @Author: zhm
 * @CreateTime: 2022-09-27  13:28
 * @Description: TODO
 * @Version: 1.0
 */
@Configuration
public class LoginConfig implements WebMvcConfigurer {

    @Resource
    private StringRedisTemplate stringRedisTemplate;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // token刷新的拦截器
        System.out.println("interceptor:" );
        registry.addInterceptor(new RefreshTokenInterceptor(stringRedisTemplate)).addPathPatterns("/**").order(1);
    }
}
